package com.me.chat.controller.bis.chat;

import com.me.chat.pojo.chat.ChatLately;
import com.me.chat.pojo.chat.qo.ChatLatelyQO;
import com.me.chat.pojo.suport.ResultBean;
import com.me.chat.service.chat.ChatLateService;
import com.me.chat.util.RedisKey;
import com.me.chat.util.SimpleUserInfo;
import com.me.chat.util.stauts.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 聊天的最近联系人控制层
 * @Authhor: qiu
 * @Date: 2021/11/23 9:40 下午
 */

@RestController
@RequestMapping("/res/chat_lately")
public class ChatLatelyController {

    @Autowired
    ChatLateService chatLateService;


    /**
     * 最近联系人查询
     * @return
     */
    @GetMapping("/search")
    public ResultBean<List<ChatLately>> getLatelyList() {
        List<ChatLately> chatLatelies = chatLateService.selChatLately();
        return new ResultBean<>(StatusCode.SUCCEED,chatLatelies,"最近联系人查询");
    }


    /**
     * 设置当前所在聊天室的标识 并且唯独数量清空
     * @param chatLatelyQO
     * @return
     */
    @PostMapping("/set_room_flag")
    public ResultBean setRoomFlag(@RequestBody ChatLatelyQO chatLatelyQO) {
        chatLateService.setRoomFlag(chatLatelyQO);
        return new ResultBean(StatusCode.SUCCEED,null,"进入聊天室前的操作");
    }

    /**
     * 删除当前所在聊天室的标识
     * @param chatLatelyQO
     * @return
     */
    @PostMapping("/remove_room_flag")
    public ResultBean removeRoomFlag(@RequestBody ChatLatelyQO chatLatelyQO) {
        chatLateService.removeRoomFlag(chatLatelyQO);
        return new ResultBean(StatusCode.SUCCEED,null,"退出聊天室前的操作");
    }


}
